using System.Collections.Generic;
using System.Xml.Serialization;

namespace Rolodex.Model
{
    [XmlRoot("cards")]
    public class CardCollection
    {
        #region Members
        private List<Card> _Cards = new List<Card>();
        #endregion

        #region Properties
        [XmlElement("card")]
        public Card[] Cards
        {
            get
            {
                Card[] theCards = new Card[this._Cards.Count];
                this._Cards.CopyTo(theCards);
                return theCards;
            }
            set
            {
                if (value == null) return;
                Card[] theCards = (Card[])value;
                this._Cards.Clear();
                foreach (Card thisRow in theCards)
                    this._Cards.Add(thisRow);
            }
        }

        [XmlIgnore]
        public List<Card> CardList
        {
            get { return this._Cards; }
        }
        #endregion

        #region Methods
        #region Constructor
        public CardCollection() { }
        #endregion

        #region Public Helpers
        public void Add(Card theCard)
        {
            this._Cards.Add(theCard);
        }

        public void Remove(Card theCard)
        {
            this._Cards.Remove(theCard);
        }
        #endregion
        #endregion
    }
}
